package cn.net.withub.dataCollector.common.init;


import cn.net.withub.dataCollector.common.utils.CommonProperties;
import cn.net.withub.dataCollector.common.utils.SpringBeanHelper;
import org.apache.log4j.Logger;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Created by LiuYang on 2016-07-06.
 */
public class InitServlet implements ServletContextListener {
    private Logger log= Logger.getLogger(this.getClass());

    // 系统初始化执行方法
    public void contextDestroyed(ServletContextEvent e) {
        log.info("系统停止...");
    }

    public void contextInitialized(ServletContextEvent e) {

        try {
            CommonProperties commonProperties=(CommonProperties) SpringBeanHelper.getBean(e.getServletContext(), "commonProperties") ;
            /*ConfigManager configManager=(ConfigManager) SpringBeanHelper.getBean(e.getServletContext(), "configManager") ;
            log.info(""+commonProperties.SYSTEM_MC+"系统初始化开始...");
            configManager.initOptions();
            configManager.initForm();
            configManager.initParam();
            configManager.initTree();*/

        } catch (Exception e1) {
            e1.printStackTrace();
        } finally{
            log.info("系统初始化结束...");
        }

    }
}
